import re
with open('static/html/index.html','r',encoding='utf-8') as f:
    html=f.read()
    # print(html)
    html=re.sub('\n','',html)
    print(html)
    pattern_1='<section class="main_section">(.*?)</section>'
    session_s=re.findall(pattern_1,html)
    print(session_s)
    print(len(session_s))
    category_pattern = '<h1>(.*?)</h1>'
    course_pattern = '<span class="course_name">(.*?)</span>'
    for section in session_s:
        category=re.findall(category_pattern,section)[0]
        # print(category)
        data_s=[]
        course_s=re.findall(course_pattern,section)
        data_s.append(
            {
                'category':category,
                'course_s':course_s
            }
        )
        # print(data_s)

        for data in data_s:
            print(data.get('category'))
            for course in data.get('course_s'):
                print('    ',course)

